<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp" %>
<script type="text/javascript">
    var appVipDataGrid;
    $(function() {
        var statusArr = ['管理员','平台用户','APP会员用户'];
        var levelArr = ['','会员','普通代理','区代理','市代理','省代理','董事'];

        appVipDataGrid = $('#appVipDataGrid').datagrid({
            url : '${path }/appVip/dataGrid',
            striped : true,
            rownumbers : true,
            pagination : true,
            singleSelect : true,
            idField : 'id',
            sortName : 'id',
            sortShip : 'asc',
            pageSize : 20,
            pageList : [ 10, 20, 30, 40, 50, 100, 200, 300, 400, 500 ],
            frozenColumns : [ [ {
                title : 'id',
                field : 'id',
                width : 40,
                hidden : true
            } ] ],
            columns : [ [ {
                field : 'loginName',
                title : '登录名',
                width : 130
            },{
                field : 'name',
                title : '昵称',
                width : 100
            },{
                field : 'phone',
                title : '手机号 ',
                width : 130
            },{
                field : 'userType',
                title : '用户状态',
                width : 100,
                formatter:function (value) {
                    return  statusArr[value];
                }
            },{
                field : 'createTime',
                title : '创建时间',
                width : 180
            },{
                field : 'action',
                title : '操作',
                width : 90,
                formatter : function(value, row, index) {
                    var str = '';
                    <shiro:hasPermission name="/appVip/edit">
                    str += $.formatString('<a href="javascript:void(0)" class="appVipDataGrid-easyui-linkbutton-edit" data-options="plain:true,iconCls:\'fi-pencil icon-blue\'" onclick="editAppUserFun(\'{0}\');" >重置密码</a>', row.id);
                    </shiro:hasPermission>

                  /*  str += '&nbsp;&nbsp;|&nbsp;&nbsp;';
                    str += $.formatString('<a href="javascript:void(0)" class="organization-easyui-linkbutton-del" data-options="plain:true,iconCls:\'fi-x icon-red\'" onclick="deleteAppUserFun(\'{0}\');" >删除</a>', row.id);
*/
                    return str;
                }
            } ] ],
            onLoadSuccess:function(data){
                $('.appVipDataGrid-easyui-linkbutton-edit').linkbutton({text:'重置密码'});
            /*    $('.appVipDataGrid-easyui-linkbutton-del').linkbutton({text:'删除'});*/
            },
            toolbar : '#appVipToolBar'
        });
    });


    function editAppUserFun(id) {
        parent.$.modalDialog({
            title : '编辑',
            width : 500,
            height : 350,
            href : '${path }/appVip/editPage?id=' + id,
            buttons : [ {
                text : '确定',
                handler : function() {
                    var f = parent.$.modalDialog.handler.find('#editUserAddChargeForm');
                    f.submit();
                }
            } ]
        });
    }

    function editOrganizationFun(id) {
        if (id != undefined) {
            organizationTreeGrid.treegrid('select', id);
        }
        var node = organizationTreeGrid.treegrid('getSelected');
        if (node) {
            parent.$.modalDialog({
                title : '编辑',
                width : 500,
                height : 300,
                href : '${path }/organization/editPage?id=' + node.id,
                buttons : [ {
                    text : '编辑',
                    handler : function() {
                        parent.$.modalDialog.openner_treeGrid = organizationTreeGrid;//因为添加成功之后，需要刷新这个treeGrid，所以先预定义好
                        var f = parent.$.modalDialog.handler.find('#organizationEditForm');
                        f.submit();
                    }
                } ]
            });
        }
    }


/*
    function deleteAppUserFun(id) {
        if (id != undefined) {
            appVipDataGrid.dataGrid('select', id);
        }
        var node = appVipDataGrid.dataGrid('getSelected');
        if (node) {
            parent.$.messager.confirm('询问', '您是否要删除当前会员？', function(b) {
                if (b) {
                    progressLoad();
                    $.post(/appVip/delete', {
                        id : node.id
                    }, function(result) {
                        if (result.success) {
                            parent.$.messager.alert('提示', result.msg, 'info');
                            appVipDataGrid.dataGrid('reload');
                        }else{
                            parent.$.messager.alert('提示', result.msg, 'info');
                        }
                        progressClose();
                    }, 'JSON');
                }
            });
        }
    }*/


/*    /!**
     * 新增会员
     * *!/
    function addAppUserFun(){
            parent.$.modalDialog({
                title : '添加VIP',
                width : 700,
                height : 500,
                href : /appVip/addPage',
                buttons : [ {
                    text : '确定',
                    handler : function() {
                                parent.$.modalDialog.openner_dataGrid = appVipDataGrid;//因为添加成功之后，需要刷新这个treeGrid，所以先预定义好
                        var f = parent.$.modalDialog.handler.find('#appUserAddForm');
                        f.submit();
                    }
                }, {
                        text : '取消',
                        handler : function() {
                            console.info( parent.$.modalDialog);
                            parent.$.modalDialog.handler.dialog('close');
                        }
                    }
                ]
            });
    }*/

    /**
     *   模板下载
     * */
    function downAppUserExcel(){
        window.location.href =  "${path}/appVip/downloadExcel";
    }

    /**
     *  上传
     * */
    function uploadAppUserExcel(){
        parent.$.modalDialog({
            title : '上传文件',
            width : 700,
            height : 500,
            href : '${path }/appVip/addUploadPage',
            buttons : [ {
                text : '确定',
                handler : function() {
                    parent.$.modalDialog.openner_dataGrid = appVipDataGrid;//因为添加成功之后，需要刷新这个dataGrid，所以先预定义好
                    var f = parent.$.modalDialog.handler.find('#appUserAddForm');
                    f.submit();
                }
            }, {
                text : '取消',
                handler : function() {
                    parent.$.modalDialog.handler.dialog('close');
                }
            }
            ]
        });
    }

</script>
<div class="easyui-layout" data-options="fit:true,bShip:false">
    <div data-options="region:'center',fit:true,bShip:false">
        <table id="appVipDataGrid" data-options="fit:true,bShip:false"></table>
    </div>
</div>
<div id="appVipToolBar" style="display: none;">
        <%-- <shiro:hasPermission name="/appVip/add">--%>
     <%--   <a onclick="addAppUserFun();" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'fi-plus icon-green'">添加</a>--%>
        <%--  </shiro:hasPermission>--%>
        <%-- <shiro:hasPermission name="/appVip/downloadExcel">--%>
        <a onclick="downAppUserExcel();" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'fi-download icon-green'">下载</a>
        <%--  </shiro:hasPermission>--%>
        <%-- <shiro:hasPermission name="/appVip/uploadExcel">--%>
        <a onclick="uploadAppUserExcel();" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'fi-upload icon-green'">上传</a>
        <%--  </shiro:hasPermission>--%>
</div>
</div>